package myaction.login;

import java.util.Map;

import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

/**
 * DI: dependency injection
 * IoC: Inversion of Control
 * 
 * This way is recommended.
 * Most ofen mySession is the necessary one.
 * 
 * @author yzt
 *
 */
public class LoginAction2 extends ActionSupport implements RequestAware, SessionAware, ApplicationAware {
	//not initialized, but the setters are called
	private Map<String, Object> myRequest;
	private Map<String, Object> mySession;
	private Map<String, Object> myApplication;
	
	public String execute() {
		myRequest.put("r1", "r2");
		mySession.put("s1", "s2");
		myApplication.put("a1", "a2");
		return SUCCESS;
	}
	
	@Override
	public void setSession(Map<String, Object> session) {
		mySession = session;
	}

	@Override
	public void setRequest(Map<String, Object> request) {
		myRequest = request;
	}

	@Override
	public void setApplication(Map<String, Object> application) {
		myApplication = application;
	}
}
